﻿using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using MiniErp.Core.Filters;
using MiniErp.Entity.DataStreams.BOs;
using MiniErp.Entity.DataStreams.DTOs.AssetManagement;
using MiniErp.Service.JWTService.IService;
using MiniErp.Service.BusinessService.IService;
using MiniErp.Service.BusinessService.IService.IAssetManagement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;

/// <summary>
/// 资产管理系统
/// </summary>
namespace MiniErp.Core.Controllers.AssetManagement
{
    /// <summary>
    /// 资产管理主页控制层
    /// </summary>
    [Route("AssetIndex")]
    public class AssetIndexController : ApiControllers
    {
        private readonly IAssetIndexService _assetIndexService;
        public AssetIndexController(IAssetIndexService assetIndexService)
        {
            _assetIndexService = assetIndexService;
        }

        /// <summary>
        /// 增加一条资产信息
        /// </summary>
        /// <param name="addassetInfoDTO">要增加的资产信息dto</param>
        /// <returns></returns>
        [HttpPost]
        [Route("AddAssetInfoAsync")]
        public Task<bool> AddAssetInfoAsync(AddAssetInfoDTO addassetInfoDTO)
        {
            return _assetIndexService.AddAssetInfoAsync(addassetInfoDTO);
        }

        /// <summary>
        /// 修改一条资产信息
        /// </summary>
        /// <param name="updateAssetInfoDTO">要修改的资产信息dto</param>
        /// <returns></returns>
        [HttpPost]
        [Route("UpdateAssetInfoAsync")]
        public Task<bool> UpdateAssetInfoAsync(UpdateAssetInfoDTO updateAssetInfoDTO)
        {
            return _assetIndexService.UpdateAssetInfoAsync(updateAssetInfoDTO);
        }

        /// <summary>
        /// 查询所有资产信息(分页)
        /// </summary>
        /// <param name="page">页码</param>
        /// <param name="num">每页数据条数</param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetAllAssetInfoAsync")]
        public Task<List<AssetInfoDTO>> GetAllAssetInfoAsync(int page, int num)
        {
            return _assetIndexService.GetAllAssetInfoAsync(page, num);
        }

        /// <summary>
        /// 模糊查询所有资产信息(分页)
        /// </summary>
        /// <param name="value">模糊查询值</param>
        /// <param name="page">页码</param>
        /// <param name="num">每页数据条数</param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetFuzzyAssetInfoAsync")]
        public Task<List<AssetInfoDTO>> GetFuzzyAssetInfoAsync(string value, int page, int num)
        {
            return _assetIndexService.GetFuzzyAssetInfoAsync(value, page, num);
        }

        /// <summary>
        /// 删除指定编号的资产信息
        /// </summary>
        /// <param name="gid">资产总类型编号</param>
        /// <param name="sid">资产次级类型编号</param>
        /// <param name="aid">资产编号</param>
        /// <returns></returns>
        [HttpDelete]
        [Route("DeleteAssetInfoAsync")]
        public Task<bool> DeleteAssetInfoAsync(int gid, int sid, int aid)
        {
            return _assetIndexService.DeleteAssetInfoAsync(gid, sid, aid);
        }

    }
}
